package cn.pku.ss.sirx.sna.ib.bean;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;

/**
 * Abstract of a message in message board.
 *
 * @author SirX
 * @version 1.0
 */
@Entity
public class Message {
    
    /**
     * Get the fromId.
     * @return the fromId
     */
    public String getFromId() {
        return fromId;
    }
    /**
     * Set the fromId.
     * @param fromId the fromId to set
     */
    public void setFromId(String fromId) {
        this.fromId = fromId;
    }
    /**
     * Get the toId.
     * @return the toId
     */
    public String getToId() {
        return toId;
    }
    /**
     * Set the toId.
     * @param toId the toId to set
     */
    public void setToId(String toId) {
        this.toId = toId;
    }
    /**
     * Get the messageBoardId.
     * @return the messageBoardId
     */
    public String getMessageBoardId() {
        return messageBoardId;
    }
    /**
     * Set the messageBoardId.
     * @param messageBoardId the messageBoardId to set
     */
    public void setMessageBoardId(String messageBoardId) {
        this.messageBoardId = messageBoardId;
    }
    /**
     * Get the time.
     * @return the time
     */
    public Date getTime() {
        return time;
    }
    /**
     * Set the time.
     * @param time the time to set
     */
    public void setTime(Date time) {
        this.time = time;
    }
    /**
     * Get the content.
     * @return the content
     */
    public String getContent() {
        return content;
    }
    /**
     * Set the content.
     * @param content the content to set
     */
    public void setContent(String content) {
        this.content = content;
    }
    /**
     * Get the isNewReply.
     * @return the isNewReply
     */
    public boolean isNewReply() {
        return isNewReply;
    }
    /**
     * Set the isNewReply.
     * @param isNewReply the isNewReply to set
     */
    public void setNewReply(boolean isNewReply) {
        this.isNewReply = isNewReply;
    }
    /**
     * Get the id.
     * @return the id
     */
    public int getId() {
        return id;
    }
    /**
     * Set the id.
     * @param id the id to set
     */
    public void setId(int id) {
        this.id = id;
    }
    @Override
    public String toString() {
        return String.format("From: %s, To: %s, Time: %3$tD %3$tT, Content: %4$s, Board: %5$s, IsNew: %6$b", 
                fromId, toId, time, content, messageBoardId, isNewReply);
    }

    //////////////////////////////////////////////////////////////////////////////

    private String fromId; // id of the one who sends this message
    private String toId; // id of the one who receives this message
    @Column(name="UserId")
    private String messageBoardId; // id of the message board where this message exists
    private Date time;
    private String content;
    private boolean isNewReply; // true if this message is not a reply to another reply
    @Id
    @Column(name="tid")
    private int id; // as a primary key in database
}
